package com.lh.java.basic.clone;

public class Test {
	 public static void main(String[] args) throws Exception {  
	        A a = new A();  
	        B b = new B();  
	        C c = new C();  
	        c.setName("ccc");  
	        b.setName("bbb");  
	        b.setC(c);  
	        a.setName("aaa");  
	        a.setB(b);  
	        System.out.println("a: " + a);  
	        System.out.println("a: " + a.getName());  
	        System.out.println("a: " + a.getB().getName());  
	        System.out.println("a: " + a.getB().getC().getName());  
	        A anotherA = (A)a.clone();  
	        System.out.println("anotherA: " + anotherA);  
	        System.out.println("anotherA: " + anotherA.getName());  
	        System.out.println("anotherA: " + anotherA.getB().getName());  
	        System.out.println("anotherA: " + anotherA.getB().getC().getName());  
	        System.out.println("=== change properties of a ===");  
	          
	        a.setName("aaaaa");  
	        a.getB().setName("bbbbb");  
	        a.getB().getC().setName("ccccc");  
	        System.out.println("a: " + a);  
	        System.out.println("a: " + a.getName());  
	        System.out.println("a: " + a.getB().getName());  
	        System.out.println("a: " + a.getB().getC().getName());  
	        System.out.println("anotherA: " + anotherA);  
	        System.out.println("anotherA: " + anotherA.getName());  
	        System.out.println("anotherA: " + anotherA.getB().getName());  
	        System.out.println("anotherA: " + anotherA.getB().getC().getName());  
	        System.out.println("=== change properties of anotherA ===");  
	          
	        anotherA.setName("aaaa");  
	        anotherA.getB().setName("bbbb");  
	        anotherA.getB().getC().setName("cccc");  
	        System.out.println("a: " + a);  
	        System.out.println("a: " + a.getName());  
	        System.out.println("a: " + a.getB().getName());  
	        System.out.println("a: " + a.getB().getC().getName());  
	        System.out.println("anotherA: " + anotherA);  
	        System.out.println("anotherA: " + anotherA.getName());  
	        System.out.println("anotherA: " + anotherA.getB().getName());  
	        System.out.println("anotherA: " + anotherA.getB().getC().getName());  
	    }  
}
